<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>视频增加</title>
    <link rel="stylesheet" th:href="@{/css/pintuer.css}">
    <link rel="stylesheet" th:href="@{/css/admin.css}">
    <script type="application/javascript" th:src="@{/js/jquery-3.5.1.js}"></script>
    <script>
        $(document).ready(function () {
            $("#myForm").submit(function () {
                var name=$("#name").val()
                var video=$("#video").val()
                if (name.length==0){
                    $("#ErrorName").html("名字不能为空!")
                    return false
                }
                $("#ErrorName").html("")
                if (video.length==0){
                    $("#ErrorVideo").html("请选择视频!")
                    return false
                }
                $("#ErrorVideo").html("")
            })
        })
    </script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head" id="add">
        <strong><span class="icon-pencil-square-o"></span>增加视频类别</strong>
    </div>
    <div class="body-content">
        <form id="myForm" method="post" enctype="multipart/form-data" class="form-x" action="/video/addVideo/">
            <div class="form-group">
                <div class="label">
                    <label>视频名称：</label>
                </div>
                <div class="field">
                    <input  type="text" id="name" class="input w50"   name="name" />
                    <div style="color: red" id="ErrorName"></div>
                </div>

            </div>
            <div class="form-group">
                <div class="label">
                    <label>选择视频：</label>
                </div>
                <div class="field">
                    <input id="video" type="file" name="videoFile" accept="video/*"/>
                    <div style="color: red" id="ErrorVideo"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>选择封面：</label>
                </div>
                <div class="field">
                    <input type="file" name="videoCover" accept="image/*"/>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>视频类别：</label>
                </div>
                <div class="field">
                    <select  id="categoryId" name="categoryId" class="input"
                                style="width:200px; line-height:17px;">
                        <option th:selected="${index.count}==1"   th:value="${category.id}" th:each="category,index:${categories}" th:text="${category.name}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <button class="button bg-main icon-check-square-o" type="submit">
                        提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
</body>
</html>